package com.leoman.systemsetting.dao;

import com.leoman.common.dao.IBaseJpaRepository;
import com.leoman.systemsetting.entity.UserTask;
import com.leoman.user.entity.UserInfo;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by Administrator on 2016/6/12.
 */
public interface UserTaskDao extends IBaseJpaRepository<UserTask> {

    @Query("select a from UserTask a where a.userInfo.id = ?1 and a.type < 6")
    List<UserTask> findListByUserId(Long userId);

    @Query("select a from UserTask a where a.userInfo.id = ?1 and a.type = ?2")
    UserTask findOneByUserIdAndType(Long userId, Integer type);

    @Query("select a from UserInfo a where a.id not in (select b.userInfo.id from UserTask b group by b.userInfo.id)")
    List<UserInfo> findListWithOutTask();

    @Query("select a from UserTask a where a.userInfo.id in (select b.id from UserInfo b)")
    List<UserTask> findValidList();

    @Query("select a from UserTask a where a.userInfo.id = ?1")
    List<UserTask> findList(Long userId);
}
